<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
<link rel="stylesheet" type="text/css" href="../css/common.css"/>
<link rel="stylesheet" type="text/css" href="../font/iconfont.css"/>
<style type="text/css">
.jtabs{
	position: fixed;
	height:3rem;
	background:#f5f5f5;
	top: 0;
	left: 0;
	width: 100%;
	z-index: 100;
	display: flex;
	display: -webkit-flex;
	font-size:16px;
}
.jtabheight{
	height:3rem;
}
.jtab-item{
	display: block;
	flex: 1;
	-webkit-flex: 1;
	text-align: center;
	line-height:3rem;
}
.jtab-active{
	color: dodgerblue;
	border-bottom: 2px solid dodgerblue;
}
#shopimg{
	position:relative;
	font-size: 0;
}
#shopingo{
	position: absolute;
	left: 0;
	top: 0;
	width: 100%;
	height: 100%;
	overflow: hidden;
	text-align: center;
	padding: 5rem;
}
#shoptitle{
	background: rgba(0,0,0,0.3);
	border-radius: 10rem;
	padding: 0.5rem 1rem 0.5rem 1rem;
	color: #f5f5f5;
	font-size:18px;
}
#gaunzhus{
	color: #fff;
	padding-top: 0.5rem;
	font-size:14px;
}
.guanzhustitle{
	color: #FFAF00;
}
.colorred{
color: #FFAF00;
}
#guanzhuline{
	padding: 0 1rem 0 1rem;
}
#shopbtn{
	width: auto;
	height: 4rem;
	background: #fff;
	position: relative;
	display: flex;
	display: -webkit-flex;
	font-size: 18px;
	line-height: 4rem;
}
.shopbtnitem{
	display: block;
	flex: 1;
	-webkit-flex: 1;
	text-align: center;
	position: relative;
}
#shopbtnitem1,#shopbtnitem2{
	border-right: 1px solid #eee;
}
.icontb{
	color: #FFAF00;
	padding-right: 0.5rem;
	font-weight: bold;
	font-weight:bold;
}
.sheight{
	height: 1rem;
}
.shop-detail{
	padding: 1rem;
	background: #fff;
	position: relative;
}
.shopline{
	display: flex;
	display: -webkit-flex;
	height: auto;
	padding: 0.7rem 0 0.7rem 0;
	font-size: 16px;
}
.shopline-l{
	color: #888;
	padding-right: 0.5rem;
}
.shopline-r{
	flex: 1;
	-webkit-flex: 1;
}
.icon-list{
	padding-right: 0.5rem;
	color: dodgerblue;
	font-size:14px;
	line-height: 1.7rem;
}
.shop-content-img{
	position: relative;
	padding-top: 1rem;
}
</style>
</head>
<body>
<div id="jcontent" class="jcontent">
	<div class="jtabs">
		<a class="jtab-item jtab-active"><i class="iconfont icon-dianjia"></i>&nbsp;&nbsp;主页</a>
		<a id="dt" class="jtab-item"><i class="iconfont icon-dongtaidongtai"></i>&nbsp;&nbsp;动态</a>
	</div>
	<div class="jtabheight"></div>
	<div id="shopimg">
		<img id="topimg" src="../img/zw3.png" class="img"/>
		<div id="shopingo">
			<span id="shoptitle">加载中...</span>
			<p id="gaunzhus">
				关注:&nbsp;&nbsp;<span id="followNum" class="guanzhustitle"></span>
				<span id="guanzhuline">|</span>
				粉丝:&nbsp;&nbsp;<span id="fansNum" class="guanzhustitle"></span>
			</p>
		</div>
	</div>
	<div id="shopbtn" class="line-b">
		<a class="shopbtnitem item-gz line-r"><i class="iconfont icon-gy icontb"></i><span id="guanzhu_status">关注</span></a>
		<a class="shopbtnitem item-sx line-r"><i class="iconfont icontb icon-i2"></i>私信</a>
		<!--<a class="shopbtnitem item-dt"><i class="iconfont icon-dongtaidongtai icontb"></i>动态</a>-->
	</div>
	<div class="sheight"></div>
	<div id="dianjia" class="shop-detail line-t line-b">
		<div class="shopline">
			<i class="iconfont icon-dianjia1 icon-list"></i>
			<div class="shopline-l">
				店家：
			</div>
			<div id="sellerNames" class="shopline-r"  v-cloak>
				{{shop.name}}
			</div>
		</div>
		<div class="shopline">
			<i class="iconfont icon-dizhi icon-list"></i>
			<div class="shopline-l">
				地址：
			</div>
			<div class="shopline-r"  v-cloak>
				{{shop.address}}
			</div>
		</div>
		<div class="shopline">
			<i class="iconfont icon-dianhua icon-list"></i>
			<div class="shopline-l">
				电话：
			</div>
			<div class="shopline-r"  v-cloak>
				{{shop.insuranceTel}}
			</div>
		</div>
		<div class="shopline">
			<i class="iconfont icon-renzheng icon-list"></i>
			<div class="shopline-l">
				认证：
			</div>				
				<div class="shopline-r colorred" v-if="shop.state==1"  v-cloak>
				  已经通过平台认证
				</div>
				<div class="shopline-r colorred" v-else  v-cloak>
				 未通过平台认证
				</div>
		</div>
		
		<div class="shopline">
			<i class="iconfont icon-jianjie icon-list"></i>
			<div class="shopline-l">
				简介：
			</div>
			<div class="shopline-r"  v-cloak>
				{{shop.introduction}}
			</div>
		</div>
		
		<div class="shop-content-img line-t">
			<img v-bind:src="shop.imgPath + shop.propagateImage" class="img" />
		</div>
	</div>
</div>
<script src="../js/mui.min.js" type="text/javascript" charset="utf-8"></script>
<script src="../js/common.js" type="text/javascript" charset="utf-8"></script>
<script src="../js/vue.mini.js" type="text/javascript" charset="utf-8"></script>
<script src="../js/page.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript">
var dataId;
mui.plusReady(function(){
	dataId=webapp.GetQueryString("business");
	window.setTimeout(function(){
		initData();
	},360);
	//获取该4s店的关注状态
	var _status=window.localStorage.getItem("GUANZHU_"+dataId);
	if(_status=="1"){
		document.getElementById("guanzhu_status").innerHTML="已关注";
	}
});

/**
 * 
 *  初始化加载数据
 * 
 */
function initData(){
	var data={shop:{}};
	var vm = new Vue({
		el: '#dianjia',
		data: data
	});
	//获取4s店id
	webapp.ajax({
		url:"/carLife/common/interface/seller/selectById",
		data:{
			id:dataId
		},
		success:function(json){ 
			webapp.debug(json);  
			if(json.code==200){
				json.data.imgPath=webapp.config.restUrl;
				data.shop=json.data;
				//基本信息
				document.getElementById("shoptitle").innerHTML=json.data.name;
				document.getElementById("fansNum").innerHTML=json.data.fansNum;
				document.getElementById("followNum").innerHTML=json.data.followNum;
				document.getElementById("topimg").setAttribute("src",webapp.config.restUrl+json.data.titleImage);
			}else{
				mui.toast(json.msg);
			}
		}
	});
	
	mui('#shopbtn').on('tap', '.shopbtnitem', function(e) {
		var cla=this.classList;
		if(cla.contains("item-gz")){
			guanzhu();
		}else if(cla.contains("item-sx")){
			webapp.openByTpl2({
				title:document.getElementById("sellerNames").innerHTML,
				hrefs:"/tpl/sixin.html?business="+webapp.GetQueryString("business")
			});
		}else if(cla.contains("item-dt")){
			webapp.openByTpl2({
				title:"动态信息",
				hrefs:"/tpl/dongtai.html?id="+webapp.GetQueryString("business") 
			});
		}
	});
	
	mui('#jcontent').on('tap', '#dt', function(e) {
		var shoptitle=document.getElementById("shoptitle").innerHTML;
		var fansNum=document.getElementById("fansNum").innerHTML;
		var followNum=document.getElementById("followNum").innerHTML
		var topimg=document.getElementById("topimg").getAttribute("src");
		var param="?id="+dataId+"&shoptitle="+shoptitle+"&fansNum="+fansNum+"&followNum="+followNum+"&topimg="+topimg;
		webapp.openByTpl2({
			title:"动态信息",
			hrefs:"/tpl/dongtai.html"+param 
		});
	});
}

function guanzhu(){
	//发送关注请求
	webapp.ajax({
		url:"/carLife/admin/interface/followMessage/isOrNotFollow",
		data:{
			sellerId:dataId
		},
		success:function(json){
			if(json.code=="201"){
				window.localStorage.removeItem("GUANZHU_"+dataId);
				document.getElementById("guanzhu_status").innerHTML="关注";
				var _webview=plus.webview.getWebviewById("list.html");
				mui.fire(_webview,"followStateUpdate",{code:201,id:webapp.GetQueryString("business")});
			}else if(json.code=="200"){
				window.localStorage.setItem("GUANZHU_"+dataId,"1");
				document.getElementById("guanzhu_status").innerHTML="已关注";
				var _webview=plus.webview.getWebviewById("list.html");
				mui.fire(_webview,"followStateUpdate",{code:200,id:webapp.GetQueryString("business")});
			}
			mui.toast(json.msg);
		}
	});
}
</script>
</body>
</html>
